import request from '@/utils/request';
import { requestWrapper, randomInt } from '@/utils/mock';

// 获取缓存监控信息
export function getCacheInfo() {
  return requestWrapper(
    // 真实API请求
    () => request({
      url: '/monitor/cache',
      method: 'get'
    }),
    // 模拟数据
    {
      cacheInfo: {
        redis_version: "6.2.6",
        uptime_in_seconds: 86400,
        connected_clients: randomInt(5, 20),
        used_memory_human: `${randomInt(20, 80)}M`,
        total_memory_human: "4G",
        used_cpu_sys: randomInt(10, 20),
        used_cpu_user: randomInt(8, 15)
      },
      dbSize: randomInt(10, 30),
      commandStats: [
        {
          name: "get",
          value: randomInt(1000, 5000)
        },
        {
          name: "set",
          value: randomInt(500, 2000)
        },
        {
          name: "hget",
          value: randomInt(300, 1000)
        },
        {
          name: "hset",
          value: randomInt(200, 800)
        },
        {
          name: "keys",
          value: randomInt(100, 500)
        },
        {
          name: "expire",
          value: randomInt(50, 300)
        },
        {
          name: "del",
          value: randomInt(40, 200)
        },
        {
          name: "exists",
          value: randomInt(30, 150)
        }
      ]
    }
  );
} 